package com.black.pay.formatter;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.format.Formatter;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

public class DateFormatter implements Formatter<Date> {
    Logger logger = LoggerFactory.getLogger(getClass());
    private String NORMAL_DATE_FORMAT = "yyyy-MM-dd hh:mm:ss";
    private SimpleDateFormat simpleDateFormat = new SimpleDateFormat(NORMAL_DATE_FORMAT);
    public Date parse(String s, Locale locale) throws ParseException {
        return simpleDateFormat.parse(s);
    }

    public String print(Date date, Locale locale) {
        logger.info("use date formatter");
        return simpleDateFormat.format(date);
    }
}
